import { AxesHelper, BoxGeometry, Group, Mesh, MeshLambertMaterial, Vector2, Vector3 } from "three";
import { renderColorMap } from "./colorMap.js";
// 批量创建多个长方体表示高层楼
const group1 = new Group();
group1.name = "高层";
for (let i = 0; i < 5; i++) {
    const geometry = new BoxGeometry(20, 60, 10);
    geometry.translate(10, 0, 5);
    const material = new MeshLambertMaterial({ color: renderColorMap() });
    const mesh = new Mesh(geometry, material);
    mesh.position.x = i * 30;
    group1.add(mesh);
    mesh.name = i + 1 + "号楼";
}

group1.position.y = 30;

const group2 = new Group();
group2.name = "洋房";
for (let i = 0; i < 5; i++) {
    const geometry = new BoxGeometry(20, 30, 10);
    geometry.translate(10, 0, 5);
    const material = new MeshLambertMaterial({ color: renderColorMap() });
    const mesh = new Mesh(geometry, material);
    mesh.position.x = i * 30;
    mesh.name = i + 6 + "号楼";
    group2.add(mesh);
}
group1.position.z = 50;
group2.position.y = 15;

const model = new Group();
model.name = "小区房子";
model.add(group1, group2);
model.position.set(-50, 0, -25);
console.log(model);
// 获取世界坐标和一个模型的局部坐标
const worldPosition = new Vector3();
model.getWorldPosition(worldPosition);
console.log("模型世界坐标", worldPosition);
console.log("模型坐标", model.position);
// 给子对象添加局部坐标系
const modelHelper = new AxesHelper(50);
model.add(modelHelper);
export const meshGeometry = model;
